#ifndef TREEVIEWMODEL_H
#define TREEVIEWMODEL_H

#include "data/gsdata.h"
#include "treeitem.h"

#include <QList>
#include <QAbstractItemModel>
#include <QModelIndex>
#include <QVariant>

class TreeItem;

class TreeViewModel : public QAbstractItemModel
{
    Q_OBJECT
public:
    explicit TreeViewModel(QList<GSData*>* pDataSet, QObject *parent = 0);
    ~TreeViewModel();

    QVariant data(const QModelIndex & index, int role) const;
    Qt::ItemFlags flags(const QModelIndex &index) const;
    QVariant headerData(int section, Qt::Orientation orientation,
                                       int role = Qt::DisplayRole) const;
    QModelIndex index(int row, int column,
                      const QModelIndex &parent = QModelIndex()) const;
    QModelIndex parent(const QModelIndex &index) const;
    int rowCount(const QModelIndex &parent = QModelIndex()) const;
    int columnCount(const QModelIndex &parent = QModelIndex()) const;

public slots:
    void refreshDataView(QList<GSData *> *pDataSet);

private:
    void setupModelData(QList<GSData *> *pDataSet, TreeItem *parent);
    QList<QVariant> getDataInfo(GSData* pdata);

    TreeItem *rootItem = NULL;
    QList<QVariant> rootData;
//    QList<GSData*>* pDataSet; //store the imported datas
};

#endif // TREEVIEWMODEL_H
